﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Xajhzwb.Components.Util;

namespace Xajhzwb.Components.Helper
{
    public class LogHelper
    {
        public enum LogType
        {
            Info,
            Error,
            Warning,
            RunPlanTask,
            GatherError,
            PublishError,
            UploadError,
        }

        public static void WriteLog(string taskName, LogType logType, string logMessage)
        {
            string fileName = Utils.StartupPath + "Log\\" + taskName + "_" + DateTime.Now.ToString("yyyyMMdd") + ".log";

            if(!File.Exists(fileName))
            {
                File.Create(fileName);
            }

            FileStream myStream = File.Open(fileName, FileMode.Append, FileAccess.Write, FileShare.Write);
            StreamWriter sw = new StreamWriter(myStream, Encoding.UTF8);
            sw.WriteLine(taskName + "\t" + DateTime.Now.ToString () + "\t" + "XXX" + "\t" + logMessage);
            sw.Close();
            myStream.Close();
        }
    }
}
